package cn.virens.common.fastjson;

import cn.virens.common.exception.APIException;
import com.alibaba.fastjson2.JSONReader;
import com.alibaba.fastjson2.JSONWriter;
import com.alibaba.fastjson2.filter.Filter;
import com.alibaba.fastjson2.support.config.FastJsonConfig;

import java.nio.charset.Charset;

public class FastJsonConfigBuild {

    public void addWriterFeatures(JSONWriter.Feature... writerFeature) throws APIException {
        FastJsonConfigExtend.INSTANCE.addWriterFeatures(writerFeature);
    }

    public void setWriterFeatures(JSONWriter.Feature... writerFeatures) throws APIException {
        FastJsonConfigExtend.INSTANCE.setWriterFeatures(writerFeatures);
    }

    public void addWriterFilters(Filter... writerFilter) throws APIException {
        FastJsonConfigExtend.INSTANCE.addWriterFilters(writerFilter);
    }

    public void setWriterFilters(Filter... writerFilters) throws APIException {
        FastJsonConfigExtend.INSTANCE.setWriterFilters(writerFilters);
    }

    public void addReaderFeatures(JSONReader.Feature... readerFeature) throws APIException {
        FastJsonConfigExtend.INSTANCE.addReaderFeatures(readerFeature);
    }

    public void setReaderFeatures(JSONReader.Feature... readerFeatures) throws APIException {
        FastJsonConfigExtend.INSTANCE.setReaderFeatures(readerFeatures);
    }

    public void addReaderFilters(Filter... writerFilter) throws APIException {
        FastJsonConfigExtend.INSTANCE.addReaderFilters(writerFilter);
    }

    public void setReaderFilters(Filter... readerFilters) throws APIException {
        FastJsonConfigExtend.INSTANCE.setReaderFilters(readerFilters);
    }

    public void setWriteContentLength(boolean writeContentLength) throws APIException {
        FastJsonConfigExtend.INSTANCE.setWriteContentLength(writeContentLength);
    }

    public void setDateFormat(String dateFormat) throws APIException {
        FastJsonConfigExtend.INSTANCE.setDateFormat(dateFormat);
    }

    public void setSymbolTable(String... names) throws APIException {
        FastJsonConfigExtend.INSTANCE.setSymbolTable(names);
    }

    public void setCharset(Charset charset) throws APIException {
        FastJsonConfigExtend.INSTANCE.setCharset(charset);
    }

    public void setJSONB(boolean jsonb) throws APIException {
        FastJsonConfigExtend.INSTANCE.setJSONB(jsonb);
    }

    public FastJsonConfig build() throws APIException {
        return FastJsonConfigExtend.INSTANCE;
    }
}
